package shaka.core;

import junit.framework.JUnit4TestAdapter

import org.junit.Test

import shaka.core.params.DateDiff

public class TestDateOP {
	public static junit.framework.Test suite() {
		return new JUnit4TestAdapter(TestDateOP.class);
	}

	@Test
	public void run1(){
		Date now = 'yyyy-MM-dd HH:mm:ss'.dateParse('2011-10-11 12:30:50')
		// key - {@link sk.util.face.DateDiff}
		Date nextYear = now + dateDiff(year : 1)
		Date next2Year = dateDiff(year : 1, month : 1) + nextYear
		Date prevYear = now - dateDiff(year : 1)
		DateDiff diff = nextYear - prevYear
	
		assert 'yyyy-MM-dd HH:mm:ss'.dateFormat(nextYear) == '2012-10-11 12:30:50'
		assert 'yyyy-MM-dd HH:mm:ss'.dateFormat(next2Year) == '2013-11-11 12:30:50'
		assert 'yyyy-MM-dd HH:mm:ss'.dateFormat(prevYear) == '2010-10-11 12:30:50'
		assert diff as Map == [month:0, day:0, sec:0, hour:0, min:0, year:2]
	}
}
